#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
const int M=2000001;
queue<int>q;
struct edge{int x,y;}w[M];
int i,j,k,n,m,x,y,t;
int s[M],low[M],dfn[M],scc[M];
int fi[M],ne[M],la[M],a[M];
int cnt,p[M],d[M],ins[M],num;
void add(int x,int y){
    k++;a[k]=y;
    if (fi[x]==0)fi[x]=k;else ne[la[x]]=k;
    la[x]=k;
}
void tarjan(int x){
    ins[x]=1;low[x]=dfn[x]=++num;
    s[++s[0]]=x;
    for (int i=fi[x];i;i=ne[i])
        if (!dfn[a[i]]){
            tarjan(a[i]);
            low[x]=min(low[x],low[a[i]]);
        }
        else if (ins[a[i]])low[x]=min(low[x],dfn[a[i]]);
    if (dfn[x]==low[x]){
        ++cnt;
        while (s[s[0]]!=x){
            ins[s[s[0]]]=0;
            scc[s[s[0]]]=cnt;
            s[0]--;
        }
        p[x]=cnt;ins[x]=0;scc[x]=cnt;s[0]--;
    }
}
int main(){
    scanf("%d%d",&n,&m);
    while (m--){
        int x,y,a,b;
        scanf("%d%d%d%d",&x,&a,&y,&b);
        add(x+(1-a)*n,y+b*n);
        add(y+(1-b)*n,x+a*n);
    }
    for (i=1;i<=n+n;i++)
        if (!dfn[i]){
            tarjan(i);
        }
    for (i=1;i<=n;i++)
        if (scc[i]==scc[i+n]){
            printf("IMPOSSIBLE\n");
            return 0;
        }
    printf("POSSIBLE\n");
    for (i=1;i<=n;i++)
        if (scc[i]>scc[i+n])printf("1 ");else printf("0 ");
    return 0;
}